<div class="users form">
{{if $current_action=='admin_add'}}
<?php 
echo $this->MForm->create($current_model,array(
	'url' => array('action' => 'add'),
));
?>
{{elseif $current_action=='admin_edit'}}
 <?php 
echo $this->MForm->create($current_model,array(
	'class'=>'form-horizontal form',
    'url' => array('action' => 'edit',$id,$copy),
));
?>
{{/if}}
<fieldset>
    	 
            <ul class="nav nav-tabs">
                <li class="active"><a href="#article-main" data-toggle="tab"><span>{{__('Basic Info')}} ()</span></a></li>                
            </ul>
            <div class="tab-content">
                <div id="article-main" class="tab-pane active">
                	 <?php

                	if ($current_action=='admin_add') {
                	 	echo $this->MForm->input('code_nums',array('label'=>'生成邀请码数量','required'=>'required'));
					}
					else{
						echo $this->MForm->hidden('id');
						echo $this->MForm->input('name');
					}
						echo $this->MForm->input('code_type',array('label'=>'邀请码形式','options'=> array('uppernum'=>'大写字母加数字','upper'=>'大写字母','num'=>'纯数字','lower'=>'小写字母','lowernum'=>'小写+数字','uplowernum'=>'大小写加数字',),'required'=>'required'));
						echo $this->MForm->input('code_len',array('default'=>4,'label'=>'邀请码长度位数','required'=>'required'));

				        echo $this->MForm->input('cate_id',array('type'=>'text','default'=>date('Ymd'),'required'=>'required','after'=>'邀请码批次，同一批次一个用户只允许使用一次。可以使用序号或者日期，需为数字形式')); /*,'options'=>$categories */
echo $this->MForm->input('remark');
echo $this->MForm->input('company_id');
echo $this->MForm->input('role_id',array('required'=>'required'));
echo $this->MForm->input('role_days',array('required'=>'required','default'=>30));
echo $this->MForm->input('allow_nums',array('default'=>1,'label'=>'允许使用次数','required'=>'required'));
echo $this->MForm->input('start',array('required'=>'required'));
echo $this->MForm->input('end',array('required'=>'required'));
				     ?>
				     <div class="clearfix"></div>
				  
                </div>
                
                    	
       		</div>
    
    <div class="form-group">
    	<label class="col-sm-2 control-label"></label>
    	<div class="col-sm-10 controls"><?php echo $this->MForm->submit(__('Submit'),array('id'=>'btnsubmit')); ?></div>
    </div>
    </fieldset>
	{{$this->MForm->end()}}
</div>

<script>
	$(document).ready(function(){		 
		$('#btnsubmit').click(function(){		
			var oEditor = CKEDITOR.instances.ArticleContent;
			var content = oEditor.getData();
			$('#ArticleContent').val(content);
			if(typeof(before_submit)=="function"){
				if(before_submit()==false)
					return false;
			}
			try {
				var hasfile = false;
				for(var i=0;i<swfu_array.length;i++){
					var stats = swfu_array[i].getStats();
					if(stats && stats.files_queued ==0){
						continue;
					}
					else if(stats){
						hasfile = true;
						swfu_array[i].startUpload();
					}
				}
				if(!hasfile){
					// 无正在上传的文件 ,直接提交表单  
					return true;			
				}
				else{
					form_submit_flag_for_swfupload = true;
					form_submit_obj_for_swfupload = this.form; //传递表单对象 
					alert("有文件正在上传，请稍候...");
				}
			} catch (ex) {
		
			}
			return false;	
		});
	});
</script>
